//
//  RTJUserCenterCell.m
//  RuiTaiJinProject
//
//  Created by jayson on 2018/12/1.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import "RTJUserCenterCell.h"

@interface RTJUserCenterCell ()


@end

@implementation RTJUserCenterCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self backview:_bg_view4 viewOfcornerRadius:5];
    [self backview:_bg_view5 viewOfcornerRadius:5];
    
    _btn2.layer.cornerRadius = _btn2.height/2;
    _btn2.layer.masksToBounds = YES;
    _btn2.layer.borderColor = [UIColor whiteColor].CGColor;
    _btn2.layer.borderWidth = 1;
    
    [_btn addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn1 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn2 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn3 addTarget:self action:@selector(buttonOfTags:) forControlEvents:UIControlEventTouchUpInside];
    [_btn4 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn5 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn6 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn7 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn8 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn9 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn10 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn11 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn12 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn13 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn15 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn16 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn17 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];
    [_btn18 addTarget:self action:@selector(buttonOfTag:) forControlEvents:UIControlEventTouchUpInside];

    _userName.text = [RTJUserTool isLogin]==YES ?( [RTJUserTool getTheUserModel].user_name.length!=0 ? [RTJUserTool getTheUserModel].user_name:[NSString stringWithFormat:@"%ld",(long)[RTJUserTool getTheUserModel].mobile]) :@"我的账户";
    
    _userImg.layer.cornerRadius = _userImg.width/2;
    _userImg.layer.masksToBounds = YES;
   

    NSString* avatarurl = [[NSUserDefaults standardUserDefaults] objectForKey:@"avatarurl"];

    [_userImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL,avatarurl.length!=0 ? avatarurl : [RTJUserTool getTheUserModel].avatar]] placeholderImage:[UIImage imageNamed:@"icon_yhid"]];
    
//    [_userImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IMGURL, [RTJUserTool getTheUserModel].avatar]] placeholderImage:[UIImage imageNamed:@"icon_yhid"]];

    
}

- (void)buttonOfTags:(UIButton *)sender {
    
    sender.selected =!sender.selected;

    [self.delegate buttonOfAction:sender.selected];
    
}

-(void)backview:(UIView *)backview viewOfcornerRadius:(NSInteger)cornerRadius{
    
    backview.layer.cornerRadius = cornerRadius;
    backview.layer.shadowColor = [UIColor colorForHex:@"#dbc9cc"].CGColor;
    backview.layer.shadowOffset = CGSizeMake(-1, 1);
    backview.layer.shadowOpacity = 0.5;
    backview.layer.shadowRadius = 5;
    
}

- (void)buttonOfTag:(UIButton *)sender {
    
//    if (_delegate && [_delegate respondsToSelector:@selector(buttonOfTag:)]) {
    
        [self.delegate buttonOfTagsAction:sender.tag];
        
//    }
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
